import axios from '@/utils/axios.js'

/*
 * 用户管理模块
 */

// 新增用户
export const addUser = data => {
    return axios({
        url: 'sys/userManager/addUser.json',
        method: 'post',
        data
    })
}
// 编辑用户
export const editUser = data => {
    return axios({
        url: 'sys/userManager/editUser.json',
        method: 'post',
        data
    })
}
// 启用禁用用户
export const userEnable = params => {
    return axios({
        url: 'sys/userManager/disOrEnableUser.json',
        method: 'post',
        params
    })
}

//分页获取用户tableList列表
export const getUserList = params => {
    return axios({
        url: 'sys/getUserList',
        method: 'get',
        params,
        mock: true
    })
}

// 用户绑定角色
export const userbindRole = data => {
    return axios({
        url: 'sys/userManager/addUserRoleRel.json',
        method: 'post',
        data
    })
}

// 管理员重置密码
export const resetPW = params => {
    return axios({
        url: 'sys/userManager/resetPassword.json',
        method: 'post',
        params
    })
}

// 用户修改密码
export const updateUserPwd = params => {
    return axios({
        url: 'sys/userManager/modifyPassword.json',
        method: 'post',
        params
    })
}

// 获取用户的角色
export const getRoletByUser = params => {
    return axios({
        url: 'sys/userManager/getRoleListByUId.json',
        method: 'get',
        params
    })
}

//获取所有公司列表
export const getCompanyList = () => {
    return axios({
        url: 'sys/company/getAllCompany',
        method: 'get',
        mock: true
    })
}

// 获取角色列表
export const getAllRoleList = params => {
    return axios({
        url: 'sys/getAllRoleWithAppList',
        method: 'get',
        params,
        mock: true
    })
}

// 获取所有资源的 授权
export const getAllMenuByApp = params => {
    return axios({
        url: 'sys/res/getResList',
        method: 'get',
        params,
        mock: true
    })
}

// 角色绑定菜单
export const roleBindMenu = data => {
    return axios({
        url: 'sys/role/roleResRel',
        method: 'post',
        data,
        mock: true
    })
}

// 角色禁用启用
export const roleEnable = params => {
    return axios({
        url: 'sys/role/disOrEnableRole',
        method: 'post',
        params,
        mock: true
    })
}

// 获取角色下的所有资源
export const getMenuByRole = params => {
    return axios({
        url: 'sys/role/getAllResIdByRoleId',
        method: 'get',
        params,
        mock: true
    })
}
/*
 * 部门管理模块
 */

//新增部门
export const addDept = data => {
    return axios({
        url: 'sys/dept/addDept',
        method: 'post',
        data,
        mock: true
    })
}
// 编辑部门
export const editDept = data => {
    return axios({
        url: 'sys/dept/editDept',
        method: 'post',
        data,
        mock: true
    })
}
// 删除部门
export const deleteDept = params => {
    return axios({
        url: 'sys/dept/delDept',
        method: 'post',
        params,
        mock: true
    })
}
//分页获取部门tableList列表
export const getDeptList = params => {
    return axios({
        url: 'sys/deptManager/getDeptList.json',
        method: 'get',
        params
    })
}
// 获取部门管理列表list
export const getDeptTableList = params => {
    return axios({
        url: 'sys/dept/getDeptListWithCompany',
        method: 'get',
        params,
        mock: true
    })
}
// 获取所有部门list
export const getAllDeptList = params => {
    return axios({
        url: 'sys/deptManager/getAllDept.json',
        method: 'get',
        params
    })
}

// 获取一级部门list
export const getAllOneDept = params => {
    return axios({
        url: 'sys/deptManager/getAllOneDept.json',
        method: 'get',
        params
    })
}

// 部门启用禁用
export const deptEnable = params => {
    return axios({
        url: 'sys/deptManager/disableOrEnable.json',
        method: 'post',
        params
    })
}

/*
 * 角色管理模块
 */

//新增角色
export const addRole = data => {
    return axios({
        url: 'sys/role/addRole',
        method: 'post',
        data,
        mock: true
    })
}
// 编辑角色
export const editRole = data => {
    return axios({
        url: 'sys/role/editRole',
        method: 'post',
        data,
        mock: true
    })
}
// 删除角色
export const deleteRole = params => {
    return axios({
        url: 'sys/role/delRole',
        method: 'post',
        params
    })
}
//分页获取角色tableList列表
export const getRoleList = params => {
    return axios({
        url: 'sys/role/getRoleList',
        method: 'get',
        params,
        mock: true
    })
}

// 获取角色下的用户
export const getAuthUserByRole = params => {
    return axios({
        url: 'sys/user/getUserListInRId',
        method: 'get',
        params,
        mock: true
    })
}
// 获取不在角色下的用户
export const getUnAuthUserByRole = params => {
    return axios({
        url: 'sys/user/getUserListNotInRId',
        method: 'get',
        params,
        mock: true
    })
}

// 角色绑定用户
export const roleAuthUser = data => {
    return axios({
        url: 'sys/user/addRoleUserRel',
        method: 'post',
        data,
        mock: true
    })
}

// 删除角色下的用户 取消授权
export const roleUnAuthUser = data => {
    return axios({
        url: 'sys/user/delRoleUserRel',
        method: 'post',
        data,
        mock: true
    })
}

// // 分页查询
// export const findPage = data => {
//     return axios({
//         url: '/user/findPage',
//         method: 'post',
//         data
//     })
// }

// 导出Excel用户信息
export const exportUserExcelFile = data => {
    return axios({
        url: '/user/exportUserExcelFile',
        method: 'post',
        data
    })
}
// 查找用户的菜单权限标识集合
export const findPermissions = params => {
    return axios({
        url: '/user/findPermissions',
        method: 'get',
        params
    })
}
// 根据用户名查找
export const findByName = params => {
    return axios({
        url: '/user/findByName',
        method: 'get',
        params
    })
}
// 更新用户密码
export const updatePassword = params => {
    return axios({
        url: '/user/updatePassword',
        method: 'get',
        params
    })
}
// 获取用户信息
export const getCurrentUser = () => {
    return axios({
        url: '/base/userinfo/getCurrentUser.json',
        method: 'get'
    })
}
